package redis

import (
	"time"

	"github.com/gomodule/redigo/redis"
)

// 定义一个全局的pool
var Pool *redis.Pool

// 当启动程序时，就初始化连接池
func InitPool(address string, passWord string, maxIdle int, maxActive int, idleTimeout time.Duration) {
	Pool = &redis.Pool{
		MaxIdle:     maxIdle,   //最大空闲链接数
		MaxActive:   maxActive, //和数据库最大链接数，0表示没有限制
		IdleTimeout: idleTimeout,
		Dial: func() (redis.Conn, error) {
			return redis.Dial("tcp", address, redis.DialPassword(passWord))
		},
	}
}
